function Mask ()
{
	var ie6 = window.navigator.userAgent.indexOf("MSIE 6") >= 0;
    var panel = document.getElementById("_$_Mask_$_");
    var closed = false;
    var self = this;
    this.handler = null;
    var timeout = false;
    var selections = null;
        
    function init ()
    {
        if (!document.body) return;
        var ie = (window.navigator.userAgent.indexOf ("MSIE") >= 0);
        panel = document.createElement ("div");
        panel.id = "_$_Mask_$_";
        panel.style.zIndex = 100;
        panel.style.backgroundColor= '#ccccff';
        panel.style.position = 'absolute';
        panel.style.left = '0px';
        panel.style.top = '0px';
//		panel.style.width = screen.width + "px";
//		panel.style.height = screen.height + "px";
        panel.style.right = 0;
        panel.style.bottom = 0;
		panel.style.display = "none";
		if (ie) panel.style.filter = "alpha(opacity=50)";
		else panel.style.opacity = 0.5;
				
		document.body.appendChild (panel);
//		panel.style.height = (document.body.clientHeight + 20)+ "px";
//		panel.style.width = document.body.clientWidth + "px";
		
		if (ie6)
		{
			selections = document.getElementsByTagName ("select");
		}    
    }
    
    init ();

    function getSplash () {
        var splash = document.getElementById("_$_Splash_$_");
        if (!splash) {
            splash = document.createElement("div");
            splash.style.width = "200px";
            splash.style.height = "60px";
            splash.style.backgroundColor = 'lightyellow';
            splash.style.position = "absolute";
            splash.style.border = "1px solid black";
            splash.style.zIndex = "201";
            splash.innerHTML = "<table width = '100%' height = '100%'><tr><td align = 'center' valign = 'middle'>" +
                               "<img src='images/loading.gif'> <span id='_$_message_$_'></span></td></tr></table>";
            splash.id = "_$_Splash_$_";
            document.body.appendChild(splash);

            var left = (document.body.clientWidth - 200) / 2;
            var top  = (document.body.clientHeight - 100) / 2;
            splash.style.left = left + "px";
            splash.style.top  = top + "px";
        }

        return splash;
    }

    this.Mask = function () {
        if (!panel) init ();
        if (ie6 && selections) for (var i = 0; i < selections.length; i ++) {
			selections [i].disabled = true;
        }
        panel.style.height = document.body.clientHeight + "px";
        panel.style.display = 'block';
    }

    this.Unmask = function () {
        if (ie6 && selections) for (var i = 0; i < selections.length; i ++) {
			selections [i].disabled = false;
        }    
        if(panel) panel.style.display = "none";
    }

    this.ShowSplash = function (message, delay) {
        closed = false;
        function _$_ () {
            if (timeout) return ;
            if (!closed) {
                self.Mask();
                var splash = getSplash ();
                splash.style.display = 'block';
                document.getElementById("_$_message_$_").innerHTML = message;
            }
        }

        if (delay) this.handler = setTimeout (_$_, delay);
        else _$_ ();
    }

    this.HideSplash = function () {
        closed = true;
        timeout = true;        
        var splash = getSplash ();
        splash.style.display = 'none';
        this.Unmask();
        if (this.handler) clearTimeout(this.handler);
        this.handler = null;
    }    
}